﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NTmdb.TestProject
{
    /// <summary>
    ///     This is a test class for StringExtensionTest and is intended
    ///     to contain all StringExtensionTest Unit Tests
    /// </summary>
    [TestClass]
    public class StringExtensionTest
    {
        /// <summary>
        ///     A test for GetImageOriginalSizeUrl
        /// </summary>
        [TestMethod]
        public void GetImageOriginalSizeUrlTest()
        {
            var filePath = Guid.NewGuid().ToString();
            var tmdbConfig = new TmdbConfiguration
                {
                    ImageConfiguration = new TmdbImageConfiguration
                        {
                            SecureBaseUrl = Guid.NewGuid().ToString(),
                            BaseUrl = Guid.NewGuid().ToString()
                        }
                };
            var apiConfig = new ApiConfiguration
                {
                    UseSecureConnection = false,
                    OriginalImageSizeValue = Guid.NewGuid().ToString()
                };

            Assert.AreEqual( String.Format( "{0}/{1}/{2}", tmdbConfig.ImageConfiguration.BaseUrl, apiConfig.OriginalImageSizeValue, filePath ),
                             filePath.GetImageOriginalSizeUrl( apiConfig, tmdbConfig ) );
        }

        /// <summary>
        ///     A test for GetImageOriginalSizeUrl
        /// </summary>
        [TestMethod]
        public void GetImageOriginalSizeUrlTest1()
        {
            var filePath = Guid.NewGuid().ToString();
            var tmdbConfig = new TmdbConfiguration
                {
                    ImageConfiguration = new TmdbImageConfiguration
                        {
                            SecureBaseUrl = Guid.NewGuid().ToString(),
                            BaseUrl = Guid.NewGuid().ToString()
                        }
                };
            var apiConfig = new ApiConfiguration
                {
                    UseSecureConnection = true,
                    OriginalImageSizeValue = Guid.NewGuid().ToString()
                };

            Assert.AreEqual( String.Format( "{0}/{1}/{2}", tmdbConfig.ImageConfiguration.SecureBaseUrl, apiConfig.OriginalImageSizeValue, filePath ),
                             filePath.GetImageOriginalSizeUrl( apiConfig, tmdbConfig ) );
        }

        /// <summary>
        ///     A test for GetImageUrl
        /// </summary>
        [TestMethod]
        public void GetImageUrlTest()
        {
            var filePath = Guid.NewGuid().ToString();
            var size = new Random().Next( 0, Int32.MaxValue );
            var tmdbConfig = new TmdbConfiguration
                {
                    ImageConfiguration = new TmdbImageConfiguration
                        {
                            SecureBaseUrl = Guid.NewGuid().ToString(),
                            BaseUrl = Guid.NewGuid().ToString()
                        }
                };
            var apiConfig = new ApiConfiguration
                {
                    UseSecureConnection = false
                };

            Assert.AreEqual( String.Format( "{0}/{1}/{2}", tmdbConfig.ImageConfiguration.BaseUrl, size, filePath ),
                             filePath.GetImageUrl( size.ToString(), apiConfig, tmdbConfig ) );
        }

        /// <summary>
        ///     A test for GetImageUrl
        /// </summary>
        [TestMethod]
        public void GetImageUrlTest1()
        {
            var filePath = Guid.NewGuid().ToString();
            var size = new Random().Next( 0, Int32.MaxValue );
            var tmdbConfig = new TmdbConfiguration
                {
                    ImageConfiguration = new TmdbImageConfiguration
                        {
                            SecureBaseUrl = Guid.NewGuid().ToString(),
                            BaseUrl = Guid.NewGuid().ToString()
                        }
                };
            var apiConfig = new ApiConfiguration
                {
                    UseSecureConnection = true
                };

            Assert.AreEqual( String.Format( "{0}/{1}/{2}", tmdbConfig.ImageConfiguration.SecureBaseUrl, size, filePath ),
                             filePath.GetImageUrl( size.ToString(), apiConfig, tmdbConfig ) );
        }
    }
}